<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <form class="form-inline" action="" method="get">
                                <!-- <a class="btn btn-info" href="{:U('add')}" value="">新增</a> -->
                                <label class="inline">&nbsp;&nbsp;用户搜索 </label>
                                <select name="field" class="form-control">
                                    <option <if condition="I('field') eq user">selected</if> value="user">用户名</option>
                                    <option <if condition="I('field') eq phone">selected</if> value="phone">电话</option>
                                    <option <if condition="I('field') eq qq">selected</if> value="qq">QQ</option>
                                    <option <if condition="I('field') eq email">selected</if> value="email">邮箱</option>
                                </select>
                                <input type="text" name="keyword" value="{:I(keyword)}" class="form-control">

                                <label class="inline">&nbsp;&nbsp;注册起始时间 </label>
                                <div class="input-group">
                                    <input type="text" class="date-picker" name="daterange" id="starttime-endtime" data-date-format="yyyy-mm-dd" />
                                    <span class="input-group-addon"> 到</span>
                                </div>
                                <div class="input-group">
                                    <input type="text" class="date-picker" name="daterange" id="starttime-endtime" data-date-format="yyyy-mm-dd" />
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                </div>

                                <label class="inline">&nbsp;&nbsp;排序：</label>
                                <select name="order" class="form-control">
                                    <option <if condition="I('order') eq asc">selected</if> value="asc">注册时间升</option>
                                    <option <if condition="I('order') eq desc">selected</if> value="desc">注册时间降</option>
                                </select>
                                <button type="submit" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    搜索
                                </button>
                            </form>
                        </div>
                        <div class="space-4"></div>
                        <div class="row">
                            <form id="form" method="post" action="{:U('del')}">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th class="center" width="5%">
                                           <label class="pos-rel">
                                            <input class="check-all ace" type="checkbox" value="">
                                            <span class="lbl"></span>
                                           </label>
                                        </th>
                                        <th>id</th>
                                        <th>用户名</th>
                                        <th>电话</th>
                                        <th>积分</th>
                                        <th>注册时间</th>
                                        <th class="center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                        <empty name="list">
                                            <tr>
                                                <td colspan="7" class="center">没有记录</td>
                                            </tr>
                                            <else/>
                                    <volist name="list" id="val">
                                        <tr>
                                            <td class="center">
                                                <label class="pos-rel">
                                                <input class="uids ace" type="checkbox" name="uids[]" value="{$val['id']}">
                                                <span class="lbl"></span>
                                                </label>
                                            </td>
                                            <td>{$val['id']}</td>
                                            <td>{$val['name']}</td>
                                            <td>
                                                {$val['phone']}
                                            </td>
                                            <td>{$val['score']}</td>
                                            <td>{$val['createtime']}</td>
                                            <td class="center">
                                                <a href="{:U('edit',array('id'=>$val['id']))}">修改</a>
                                                &nbsp;
                                                    <a class="del" href="javascript:;"
                                                    val="{:U('del',array('id'=>$val['id']))}"
                                                    title="删除">删除</a>
                                            </td>
                                        </tr>
                                    </volist>
                                        </empty>
                                    </tbody>
                                </table>
                            </form>
                            <div class="cf">
                                <input id="submit" class="btn btn-info" type="button" value="删除">
                            </div>
                            {$page}
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".group").click(function () {
            $(this).addClass('hide');
            $(this).parent().find(".groupselect").removeClass('hide');
        })
        $(".groupselect").on("change", function () {
            var ob = $(this);
            var gid = ob.val();
            var uid = ob.parent().find('.group').attr('val');
            $.get("{:U('update')}?ajax=yes&uid=" + uid + "&gid=" + gid, function (data) {
                var text = ob.find("option:selected").text();
                ob.parent().find(".group").removeClass('hide').html(text);
                ob.addClass('hide');
            });
        })

        $(".check-all").click(function () {
            $(".uids").prop("checked", this.checked);
        });
        $(".uids").click(function () {
            var option = $(".ids");
            option.each(function (i) {
                if (!this.checked) {
                    $(".check-all").prop("checked", false);
                    return false;
                } else {
                    $(".check-all").prop("checked", true);
                }
            });
        });
        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除所选用户？",
                callback: function (result) {
                    if (result) {
                        $("#form").submit();
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除该用户?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    })
</script>
</body>
</html>
